package com.wesh.home.config;

import com.wesh.home.interceptors.FeignUserInfoRequestInterceptor;
import feign.Contract;
import feign.Logger;
import feign.Request;
import feign.auth.BasicAuthRequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * OpenFeign 配置
 */
@Configuration
public class OpenFeignConfig {

    /**
     * 配置OpenFeign日志级别
     * @return
     */
    @Bean
    public Logger.Level feignLoggerLevel(){
        return Logger.Level.FULL;
    }

    /**
     * 配置 OpenFeign 的契约
     * @return
     */
    /*@Bean
    public Contract feignContract(){
        return new Contract.Default();
    }*/

    /**
     * 配置超时时间
     */
    @Bean
    public Request.Options feignOptions(){
        return new Request.Options(5, TimeUnit.SECONDS, 10, TimeUnit.SECONDS, true);
    }

    /**
     * 配置拦截器
     * @return
     */
    @Bean
    public FeignUserInfoRequestInterceptor feignUserInfoRequestInterceptor(){
        return new FeignUserInfoRequestInterceptor();
    }

}
